package com.xxz.course;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class RateCalculateActivity extends AppCompatActivity {
    TextView t1;
    EditText t2;
    float rt;
    private static final String TAG = "out";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rate_calculate);

        Intent intent = getIntent();
        String cur = intent.getStringExtra("cur_key");
        rt = intent.getFloatExtra("rate_key",0.0f);

        Log.i(TAG,"onCreate: currency="+cur);
        Log.i(TAG,"onCreate: rate="+rt);

        t1 = (TextView) findViewById(R.id.output);
        t1.setText(cur);
    }

    public void calculate(View btn) {
        Log.i(TAG, "save:");
        //获取新的值
        t2 = (EditText)findViewById(R.id.input);
        float rmb = Float.parseFloat(t2.getText().toString());
        Log.i(TAG, "rmb= "+t2);
        float x = (100*rmb)/rt;
        t1.setText(""+x);
    }
}